<?php
require(dirname(__FILE__)."/includes/init.php");
if(isset($_SESSION['user_name'])){
$pg = isset($_REQUEST['pg'])?$_REQUEST['pg']:'1';
$type = isset($_REQUEST['submitype'])?$_REQUEST['type']:'';
$type = is_numeric($type)?$type:'';
$pageNum = $GLOBALS['pageSize'];
$nextPage = $pageNum * ($pg-1);
if(empty($type)){
	$sql = "select * from num order by id desc limit $nextPage,$pageNum";
}else{
	$sql = "select * from num where emailNumType = $type order by id desc limit $nextPage,$pageNum";
}
$result = $GLOBALS['db']->dbfetchAll($sql);
?>
<table width="1017" height="126" border="0" bgcolor="#0033FF">
  <tr bgcolor="#FFFFFF">
    <td>种类</td>
    <td><form action="" method="post"><input name="type" type="text" id="type" /><input type="submit" name="submitype" value="submitype"/></form></td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td colspan="3">&nbsp;</td>
  </tr>
  <tr bgcolor="#FFFFFF">
    <td>ID</td>
    <td>已经发送的量</td>
    <td>TempCache</td>
    <td>模板ID</td>
    <td>种类</td>
    <td>是否已用</td>
    <td>时间</td>
    <td colspan="2">操作</td>
  </tr>
<?php foreach($result as $value){?>  
  <tr bgcolor="#FFFFFF">
    <td><div align="center"><?php echo $value['id'];?></div></td>
    <td><div align="center"><?php echo $value['num'];?></div></td>
    <td><div align="center"><?php echo $value['temp'];?></div></td>
    <td><div align="center"><?php echo $value['templateId'];?></div></td>
    <td><div align="center"><?php echo $value['emailNumType'];?></div></td>
    <td><div align="center"><?php echo $value['flag'];?></div></td>
    <td><div align="center"><?php echo date("Y-m-d H:i:s",$value['timeStamps']);?></div></td>
    <td><div align="center"><a href="editListTemplate.php?id=<?php echo $value['id']; ?>" target="_blank">编辑<a/></div></td>
    <td><div align="center"><a href="editListTemplate.php?id=<?php echo $value['id']; ?>&act=del" target="_blank">删除<a/></div></td>
  </tr>
<?php } ?>
  <tr bgcolor="#FFFFFF">
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr bgcolor="#FFFFFF">
    <td>&nbsp;</td>
    <td colspan="5"><?php
	 if(empty($type)){
	 	$sql = "select count(*) from num";
	 }else{
	 	$sql = "select count(*) from num where emailNumType = $type";
	 }
	 $totalNum = $GLOBALS['db']->dbGetRow($sql);
	 $page = new Pager($totalNum[0],$pageNum,$style="page"); ?></td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
</table>
<?php }
else{
	exit("hello");
}
?>